﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LX.Web.Excel;
using S4Store.Domain.AfterSaleKpi;

namespace S4Store.Domain.AfterSaleReport
{
    public class SAReport: ExportObject
    {

        #region 数据导出
        public override bool? Discriminate(string propertyname)
        {
           
            return null;
        }
        #endregion


        public int Year { get; set; }
        public int Month { get; set; }
        public int Day { get; set; }
        public List<AfterSaleServiceAdvisorMonthTarget> M { get; set; }
        public List<AfterSaleServiceAdvisorDayInput> D { get; set; }
        public Store Store { get; set; }

        protected bool showlastday = false;
        public virtual void ShowLastDay(bool value)
        {
            showlastday = value;
        }

        [Export("职员姓名")]
        public string EmployName
        {
            get;
            set;
        }

        [Export("接待前台职业资质")]
        public int WorkYear
        {
            get;
            set;
        }


        [Export("上月末分管客户总数")]
        public int SYMFGKHZS
        {
            get
            {
                return M.Sum(o => o.SYMFGKHZS_LastMonthManageCustomerNum);
            }
        }

        [Export("月初六月未回厂数")]
        public int YCLYWHCS
        {
            get
            {
                return M.Sum(o => o.LGYWHCZS);
            }
        }

        [Export("本月新增六个月未回厂数")]
        public int BYXZLGYWHCS
        {
            get
            {
                return D.Sum(o => o.XZLGYWHCS);
            }
        }

        [Export("六个月未回厂客户总数")]
        public int LGYWHCKHZS
        {
            get
            {
                return YCLYWHCS + BYXZLGYWHCS - LSKHCXHCS;
            }
        }

        [Export("月初四个月未回厂数")]
        public int YCSGYWHCS
        {
            get
            {
                return M.Sum(o => o.SGYWHCZS);
            }
        }

        [Export("本月新增四个月未回厂数")]
        public int BYXZSGYWHCS
        {
            get
            {
                return D.Sum(o => o.XZSGYWHCS);
            }
        }

        [Export("四个月未回厂客户总数")]
        public int SGYWHCKHZS
        {
            get
            {
                return YCSGYWHCS + BYXZSGYWHCS;
            }
        }

        [Export("本月A卡转C卡客户数")]
        public int BYAKZCKKHS
        {
            get
            {
                return D.Sum(o => o.BYAKZCKKHS_ACard2CCard);
            }
        }

        [Export("分管保有客户总数")]
        public int FGBYKHZS
        {
            get
            {
                return SYMFGKHZS + BYAKZCKKHS - LGYWHCKHZS;
            }
        }        

        [Export("本月应实施5K保养数")]
        public int BYYSS5KBYS
        {
            get
            {
                return M.Sum(o => o.BYYSSWKBYS_5KMaintenceTarget);
            }
        }

        [Export("本月应实施10K保养数")]
        public int BYYSS10KBYS
        {
            get
            {
                return M.Sum(o => o.BYYSSSQBYS_10KMaintenceTarget);
            }
        }

        [Export("本月招徕回厂目标数")]
        public int BYZLHCMBS
        {
            get
            {
                return M.Sum(o => o.BYYZHCMBS_ReturnFactoryTarget);
            }
        }

        [Export("本月目标预约入厂台次")]
        public int BYMBYYRCTC
        {
            get
            {
                return 0;
            }
        }

        [Export("本月事故车入厂台次目标")]
        public int BYSGCRCTCMB
        {
            get
            {
                return M.Sum(o => o.BYSGCRCTCMB_AccidentCarToFactoryTarget);
            }
        }

        [Export("本月维修入厂台次目标")]
        public int BYWXRCTCMB
        {
            get
            {
                return M.Sum(o => o.BYWXRCTCMB_MaintenceCarToFactoryTarget);
            }
        }

        [Export("目标入厂台次")]
        public int MBRCTC
        {
            get
            {
                return M.Sum(o => o.BYYSSWKBYS_5KMaintenceTarget + o.BYYSSSQBYS_10KMaintenceTarget + o.BYSGCRCTCMB_AccidentCarToFactoryTarget + o.BYWXRCTCMB_MaintenceCarToFactoryTarget);
            }
        }

        [Export("本月事故车产值目标")]
        public decimal BYSGCCZMB
        {
            get
            {
                return M.Sum(o => o.BYSGCCZMB_AccidentCarValueTarget);
            }
        }

        [Export("本月维修产值目标")]
        public decimal BYWXCZMB
        {
            get
            {
                return M.Sum(o => o.BYWXCZMB_MaintenceValueTarget);
            }
        }

        [Export("目标售后产值")]
        public decimal MBSHCZ
        {
            get
            {
                return M.Sum(o => o.BYWXCZMB_MaintenceValueTarget + o.BYSGCCZMB_AccidentCarValueTarget);
            }
        }

        [Export("精品目标销售额")]
        public decimal JPMBXSE
        {
            get
            {
                return M.Sum(o => o.JPMBXSE_CompetitiveSaleTarget);
            }
        }

        [Export("养护产品目标销售额")]
        public decimal YHCPMBXSE
        {
            get
            {
                return M.Sum(o => o.YHCPMBXSE_MaintenceSaleTarget);
            }
        }

        [Export("首次续保台次目标")]
        public int SCXBTCMB
        {
            get
            {
                return M.Sum(o => o.SCXBTCMB_FirstRenewTarget);
            }
        }

        [Export("二次续保台次目标")]
        public int ECXBTCMB
        {
            get
            {
                return M.Sum(o => o.ECXBTCMB_SecondRenewTarget);
            }
        }

        [Export("目标续保台次总数")]
        public int MBXBTCZS
        {
            get
            {
                return SCXBTCMB + ECXBTCMB;
            }
        }

        [Export("客户满意度考核目标")]
        public int KHMYDKHMB
        {
            get
            {
                return M.Sum(o => o.KHMYDKHMB_CustomerSatisfactionTarget);
            }
        }

        [Export("累计完成事故入厂台次")]
        public int LJWCSGRCTC
        {
            get
            {
                return D.Sum(o => o.SGRCTC_AccidentToFactory);
            }
        }

        [Export("累计完成维修入厂台次")]
        public int LJWCWXRCTC
        {
            get
            {
                return D.Sum(o => o.WXRCTC_MaintentceToFactory);
            }
        }

        [Export("累计完成入厂台次")]
        public int LJWCRCTC
        {
            get
            {
                return D.Sum(o => o.WXRCTC_MaintentceToFactory + o.SGRCTC_AccidentToFactory);
            }
        }

        [Export("累计完成事故车产值")]
        public decimal LJWCSGCCZ
        {
            get
            {
                return D.Sum(o => o.SGCCZ_AccidentCarValue);
            }
        }

        [Export("累计完成维修产值")]
        public decimal LJWCWXCZ
        {
            get
            {
                return D.Sum(o => o.WXCZ_MaintenceValue);
            }
        }

        [Export("累计完成售后产值")]
        public decimal LJWCSHCZ
        {
            get
            {
                return D.Sum(o => o.WXCZ_MaintenceValue + o.SGCCZ_AccidentCarValue);
            }
        }

        [Export("本月实际实施5K保养数")]
        public int BYSJSS5KBYS
        {
            get
            {
                return D.Sum(o => o.SSWQBYS_5KMaintenceNum);
            }
        }

        [Export("本月实际实施10K保养数")]
        public int BYSJSS10KBYS
        {
            get
            {
                return D.Sum(o => o.SSSQBYS_10KMaintenceNum);
            }
        }

        [Export("成功实施招徕客户数")]
        public int CGSSZLKHS
        {
            get
            {
                return D.Sum(o => o.DHZLKHS_InviteByTelNum);
            }
        }

        [Export("电话成功预约回厂数")]
        public int DHCGYYHCS
        {
            get
            {
                return D.Sum(o => o.DHCGYYHCS);
            }
        }

        [Export("累计实现预约回厂数")]
        public int LJSXYYHCS
        {
            get
            {
                return D.Sum(o => o.SXYYHCS);
            }
        }

        [Export("准时交车客户数")]
        public int ZSJCKHS
        {
            get
            {
                return D.Sum(o => o.ZSJCKHS);
            }
        }

        [Export("当日交车客户数")]
        public int DRJCKHS
        {
            get
            {
                return D.Sum(o => o.DRJCKHS);
            }
        }

        [Export("累计精品销售额")]
        public decimal LJJPXSE
        {
            get
            {
                return D.Sum(o => o.LJJPXSE);
            }
        }

        [Export("累计养护产品销售额")]
        public decimal LJYHCPXSE
        {
            get
            {
                return D.Sum(o => o.LJYHCPXSE);
            }
        }

        [Export("首次续保实际完成台次")]
        public int SCXBSJWCTC
        {
            get
            {
                return D.Sum(o => o.SCXBSJWCTC);
            }
        }

        [Export("二次续保实际完成台次")]
        public int ECXBSJWCTC
        {
            get
            {
                return D.Sum(o => o.ECXBSJWCTC);
            }
        }

        [Export("续保台次完成总数")]
        public int XBTCWCZS
        {
            get
            {
                return D.Sum(o => o.ECXBSJWCTC + o.SCXBSJWCTC);
            }
        }

        [Export("流失客户重新回厂数")]
        public int LSKHCXHCS
        {
            get
            {
                return D.Sum(o => o.LSKHCXHCS);
            }
        }

        [Export("满意度回访平均得分")]
        public int MYDHFPJDF
        {
            get
            {
                return D.Sum(o => o.MYDHFPJDF);
            }
        }


        [Export("事故车入厂台次完成率", Format = "{0}%")]
        public decimal SGCRCTCWCL
        {
            get
            {
                if (BYSGCRCTCMB == 0) return 0;
                return (decimal)LJWCSGRCTC / (decimal)BYSGCRCTCMB * 100;
            }
        }

        [Export("维修车入厂台次完成率", Format = "{0}%")]
        public decimal WXCRCTCWCL
        {
            get
            {
                if (BYWXRCTCMB == 0) return 0;
                return (decimal)LJWCWXRCTC / (decimal)BYWXRCTCMB * 100;
            }
        }

        [Export("目标入厂台次完成率", Format = "{0}%")]
        public decimal MBRCTCWCL
        {
            get
            {
                if (MBRCTC == 0) return 0;
                return (decimal)LJWCRCTC / (decimal)MBRCTC * 100;
            }
        }

        [Export("事故车产值完成率", Format = "{0}%")]
        public decimal SGCCZWCL
        {
            get
            {
                if (BYSGCCZMB == 0) return 0;
                return LJWCSGCCZ / BYSGCCZMB * 100;
            }
        }

        [Export("维修车产值完成率", Format = "{0}%")]
        public decimal WXCCZWCL
        {
            get
            {
                if (BYWXCZMB == 0) return 0;
                return LJWCWXCZ / BYWXCZMB * 100;
            }
        }

        [Export("目标产值完成率", Format = "{0}%")]
        public decimal MBCZWCL
        {
            get
            {
                if (MBSHCZ == 0) return 0;
                return LJWCSHCZ / MBSHCZ * 100;
            }
        }

        [Export("平均单车维修产值")]
        public decimal PJDCWXCZ
        {
            get
            {
                if (LJWCRCTC == 0) return 0;
                return LJWCSHCZ / LJWCRCTC;
            }
        }

        [Export("5K保养实施率", Format = "{0}%")]
        public decimal _5KBYSSL
        {
            get
            {
                if (BYYSS5KBYS == 0) return 0;
                return BYSJSS5KBYS / BYYSS5KBYS * 100;
            }
        }

        [Export("10K保养实施率", Format = "{0}%")]
        public decimal _10KBYSSL
        {
            get
            {
                if (BYYSS10KBYS == 0) return 0;
                return BYSJSS10KBYS / BYYSS10KBYS * 100;
            }
        }

        [Export("招徕实施率", Format = "{0}%")]
        public decimal ZLSSL
        {
            get
            {
                if (BYZLHCMBS == 0) return 0;
                return CGSSZLKHS / BYZLHCMBS * 100;
            }
        }

        [Export("招徕实施完成差异", Format = "{0}%")]
        public decimal ZLSSWCCY
        {
            get
            {
                return ZLSSL - 90;
            }
        }

        [Export("预约成功率", Format = "{0}%")]
        public decimal YYCGL
        {
            get
            {
                if (LJWCRCTC == 0) return 0;
                return LJSXYYHCS / LJWCRCTC * 100;
            }
        }

        [Export("失约率", Format = "{0}%")]
        public decimal SYL
        {
            get
            {
                if (DHCGYYHCS == 0) return 0;
                return (DHCGYYHCS-LJSXYYHCS) / DHCGYYHCS * 100;
            }
        }

        [Export("准时交车率", Format = "{0}%")]
        public decimal ZSJCL
        {
            get
            {
                if (LJWCRCTC == 0) return 0;
                return ZSJCKHS / LJWCRCTC * 100;
            }
        }

        [Export("精品销售额完成率", Format = "{0}%")]
        public decimal JPXSEWCL
        {
            get
            {
                if (JPMBXSE == 0) return 0;
                return LJJPXSE / JPMBXSE * 100;
            }
        }


        [Export("精品销售率进度差", Format = "{0}%")]
        public decimal JSXSLJDC
        {
            get
            {
                return JPXSEWCL - 100;
            }
        }

        [Export("单车精品销售额")]
        public decimal DCJPXSE
        {
            get
            {
                if (LJWCRCTC == 0) return 0;
                return LJJPXSE / LJWCRCTC;
            }
        }

        [Export("养护产品销售完成率", Format = "{0}%")]
        public decimal YHCPXSWCL
        {
            get
            {
                if (YHCPMBXSE == 0) return 0;
                return LJYHCPXSE / YHCPMBXSE * 100;
            }
        }

        [Export("养护产品完成进度差", Format = "{0}%")]
        public decimal YHCPWCJDC
        {
            get
            {
                return YHCPXSWCL - 100;
            }
        }

        [Export("首次续保完成率", Format = "{0}%")]
        public decimal SCXBWCL
        {
            get
            {
                if (SCXBTCMB == 0) return 0;
                return SCXBSJWCTC / SCXBTCMB * 100;
            }
        }

        [Export("二次续保完成率", Format = "{0}%")]
        public decimal ECXBWCL
        {
            get
            {
                if (ECXBTCMB == 0) return 0;
                return ECXBSJWCTC / ECXBTCMB * 100;
            }
        }

        [Export("续保目标完成率", Format = "{0}%")]
        public decimal XBMBWCL
        {
            get
            {
                if (MBXBTCZS == 0) return 0;
                return XBTCWCZS / MBXBTCZS * 100;
            }
        }

        [Export("事实客户流失率", Format = "{0}%")]
        public decimal SSKHLSL
        {
            get
            {
                if (FGBYKHZS == 0) return 0;
                return LGYWHCKHZS / FGBYKHZS * 100;
            }
        }

        [Export("隐性客户流失率", Format = "{0}%")]
        public decimal YXKHLSL
        {
            get
            {
                if (FGBYKHZS == 0) return 0;
                return YCSGYWHCS / FGBYKHZS * 100;
            }
        }

        [Export("流失客户回归率", Format = "{0}%")]
        public decimal LSKHHGL
        {
            get
            {
                if (LGYWHCKHZS == 0) return 0;
                return LSKHCXHCS / LGYWHCKHZS * 100;
            }
        }


    }
}
